<style>
    .layui-iconpicker-body.layui-iconpicker-body-page .hide {
        display: none;
    }
</style>
<link rel="stylesheet" href="__STATIC__/plugs/lay-module/autocomplete/autocomplete.css?v={$version}" media="all">
<div class="layuimini-container">
    <form id="app-form" class="layui-form layuimini-form">

        <div class="layui-form-item  layui-row layui-col-xs12">
            <label class="layui-form-label required">上级菜单</label>
            <div class="layui-input-block">
                <select name="pid">
                    {foreach $pidMenuList as $vo}
                    <option value="{$vo.id}" {if $row.pid==$vo.id}selected=""{/if}>{$vo.name|default=''}</option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">区划名称</label>
            <div class="layui-input-block">
                <input type="text" name='name' class="layui-input" lay-verify="required" lay-reqtext="请输入区划名称" placeholder="请输入区划名称" value="{$row.name|default=''}">
                <tip>填写区划名称。</tip>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">target属性</label>
            <div class="layui-input-block">
                {foreach ['区县','乡镇','社区'] as $k=>$vo}
                <input type="radio" name="level" id="level{$k}" value="{$vo}" title="{$vo}" {if $row.level==$vo}checked=""{/if}>
                {/foreach}
            </div>
        </div>

        <div class="hr-line"></div>
        <div class="layui-form-item text-center">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit>确认</button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
        </div>
    </form>
    <script>
        layui.use(['form'])
        {
            var form = layui.form
            form.on('select(pid)', function (data) {
                var pid =  data.value
                if (pid > 0) {
                    $.post("getParent", {id: pid}, function (res) {
                        if (res.level == '区县') {
                            $("#level1").val('乡镇')
                            $('#level1').prop('checked','true')
                            form.render('radio')
                        }else {
                            $("#level2").val('社区')
                            $('#level2').prop('checked','true')
                            form.render('radio')
                        }
                    })
                }else{
                    $("#level0").val('区县')
                    $('#level0').prop('checked','true')
                    form.render('radio')
                }

            })
        }
    </script>
</div>